package com.citycloud.ccuap.tc.yq.meatbustype;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.SelectProvider;

import com.citycloud.ccuap.commons.db.SqlRestrictions;
import com.citycloud.ccuap.tc.yq.entity.MetaBusType;

@Mapper
public interface BusTypeMapper {
	
	@SelectProvider(type = SqlProvider.class, method = "findByFieldId")
	@ResultMap("com.citycloud.ccuap.tc.yq.entity.MetaBusType.ResultMapExt")
	MetaBusType findByFieldId(String fieldId);

	class SqlProvider {
		public String findByFieldId(String fieldId) {
			StringBuffer sql = new StringBuffer("SELECT * FROM ap_t_meta_bus_type as atm_bt LEFT JOIN " +
					"ap_t_meta_field_view atm_f on atm_bt.OBJ_ID = atm_f.BUS_TYPE WHERE 1 =1 ");
			sql.append(SqlRestrictions.eq("atm_f.OBJ_ID", fieldId));
			return sql.toString();
		}
	}
}
